home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 51 / Amiga Format CD51 (2000-03-10)(Future Publishing)(GB)[!][issue 2000-04].iso / -in_the_mag- / workbench / term_4.8 / extras / source / gtlayout-source.lha / LTP_AdjustItemPosition.c < prev    next >
C/C++ Source or Header  |  1997-05-08  |  1KB  |  59 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1997 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. #include "Assert.h"
  15.  
  16. #ifdef DO_MENUS
  17.  
  18.     /* LTP_AdjustItemPosition(struct MenuItem *Item,WORD Left,WORD Top):
  19.      *
  20.      *    Calculate the effective positions of the menu items.
  21.      */
  22.  
  23. LONG
  24. LTP_AdjustItemPosition(struct MenuItem *Item,LONG Left,LONG Top)
  25. {
  26.     ItemNode    *Node;
  27.     LONG         Width = 0;
  28.  
  29.         // Hit the road, Jack...
  30.  
  31.     while(Item)
  32.     {
  33.             // Get back
  34.  
  35.         Node = (ItemNode *)((ULONG)Item - sizeof(struct MinNode));
  36.  
  37.             // Add up the left edge
  38.  
  39.         Node->Left    = Left    + Node->Item.LeftEdge;
  40.         Node->Top    = Top    + Node->Item.TopEdge;
  41.  
  42.             // Fix up the sub menu
  43.  
  44.         if(Node->Item.SubItem)
  45.             Node->Width = LTP_AdjustItemPosition(Node->Item.SubItem,Node->Left,Node->Top);
  46.  
  47.             // Update the local width
  48.  
  49.         if(Node->Item.LeftEdge + Node->Item.Width > Width)
  50.             Width = Node->Item.LeftEdge + Node->Item.Width;
  51.  
  52.         Item = Item->NextItem;
  53.     }
  54.  
  55.     return(Width);
  56. }
  57.  
  58. #endif    /* DO_MENUS */
  59.